package com.ruoyi.uniRole.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.uniRole.domain.UniappRole;
import com.ruoyi.uniRole.service.IUniappRoleService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 人员身份Controller
 * 
 * @author ruoyi
 * @date 2025-05-05
 */
@RestController
@RequestMapping("/uniRole/uniRole")
public class UniappRoleController extends BaseController
{
    @Autowired
    private IUniappRoleService uniappRoleService;

    /**
     * 查询人员身份列表
     */
    @PreAuthorize("@ss.hasPermi('uniRole:uniRole:list')")
    @GetMapping("/list")
    public TableDataInfo list(UniappRole uniappRole)
    {
        startPage();
        List<UniappRole> list = uniappRoleService.selectUniappRoleList(uniappRole);
        return getDataTable(list);
    }

    /**
     * 导出人员身份列表
     */
    @PreAuthorize("@ss.hasPermi('uniRole:uniRole:export')")
    @Log(title = "人员身份", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UniappRole uniappRole)
    {
        List<UniappRole> list = uniappRoleService.selectUniappRoleList(uniappRole);
        ExcelUtil<UniappRole> util = new ExcelUtil<UniappRole>(UniappRole.class);
        util.exportExcel(response, list, "人员身份数据");
    }

    /**
     * 获取人员身份详细信息
     */
    @PreAuthorize("@ss.hasPermi('uniRole:uniRole:query')")
    @GetMapping(value = "/{roleId}")
    public AjaxResult getInfo(@PathVariable("roleId") Long roleId)
    {
        return success(uniappRoleService.selectUniappRoleByRoleId(roleId));
    }

    /**
     * 新增人员身份
     */
    @PreAuthorize("@ss.hasPermi('uniRole:uniRole:add')")
    @Log(title = "人员身份", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UniappRole uniappRole)
    {
        return toAjax(uniappRoleService.insertUniappRole(uniappRole));
    }

    /**
     * 修改人员身份
     */
    @PreAuthorize("@ss.hasPermi('uniRole:uniRole:edit')")
    @Log(title = "人员身份", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UniappRole uniappRole)
    {
        return toAjax(uniappRoleService.updateUniappRole(uniappRole));
    }

    /**
     * 删除人员身份
     */
    @PreAuthorize("@ss.hasPermi('uniRole:uniRole:remove')")
    @Log(title = "人员身份", businessType = BusinessType.DELETE)
	@DeleteMapping("/{roleIds}")
    public AjaxResult remove(@PathVariable Long[] roleIds)
    {
        return toAjax(uniappRoleService.deleteUniappRoleByRoleIds(roleIds));
    }
}
